package com.open.demo.flow

import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn

/**
 *
 * @Author: hailong.qiu hailong.qiu@xgimi.com
 * @Maintainer: hailong.qiu hailong.qiu@xgimi.com
 * @Date: 2021/8/3
 * @Copyright: 2021 www.xgimi.com Inc. All rights reserved.
 */
class NewRemoteDataSource {

    val latestNews = flow<List<String>> {
        for (i in 1..10) {
            emit(arrayListOf("Hello$i", "flow$i", "demo$i", "long$i"))
            delay(2000)
        }
    }.flowOn(Dispatchers.IO)

}